package com.starsoft.quant.bean;

public class QuantModelColumn implements Comparable<QuantModelColumn>{
	private String fieldName;
	private String name;
	private String type;
	private Integer order;
	private String format;

	public String getFieldName() {
		return fieldName;
	}
	public void setFieldName(String fieldName) {
		this.fieldName = fieldName;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public Integer getOrder() {
		return order;
	}
	public void setOrder(Integer order) {
		this.order = order;
	}
	public String getFormat() {
		return format;
	}
	public void setFormat(String format) {
		this.format = format;
	}

	@Override
	public int compareTo(QuantModelColumn o) {
		if(o.getOrder()==null && this.getOrder()==null){
			Integer a = Integer.parseInt(this.getFieldName().substring(3));
			Integer b = Integer.parseInt(o.getFieldName().substring(3));
			return a.compareTo(b);
		} else if (o.getOrder()==null){
			return -1;
		} else if(this.getOrder()==null){
			return 1;
		} else {
			return this.getOrder().compareTo(o.getOrder());
		}
	}

	public String toString() {
		return fieldName + ":" + name + " order:" + order;
	}
	
}